Command Line Tools¶
From the directory where the Mattermost platform is installed, a
platform
command is available for configuring the system, including:
General Administration
- Creating teams
- Creating users
- Assigning roles to users
- Resetting user passwords
- Inviting users to teams
Advanced Administration
- Permanently deleting users (use cautiously - database backup recommended before use)
- Permanently deleting teams (use cautiously - database backup recommended before use)
Advanced Automation
Available in Enterprise Edition E10 and higher
- Creating channels
- Inviting users to channels
- Removing users from channels
- Listing all channels for a team
- Restoring previously deleted channels
- Migrating sign-in options
- Resetting multi-factor authentication for a user
Using the CLI¶
To run the CLI commands, you must be in the directory that contains the Mattermost executable. On a default install of Mattermost, the directory is /opt/mattermost/bin
. The name of the executable is platform
.
For example, to get the Mattermost version on a default installation of Mattermost:
cd /opt/mattermost/bin sudo ./platform version
Using the CLI on GitLab Omnibus¶
On GitLab Omnibus, you must be in the following directory when you run CLI commands: /opt/gitlab/embedded/service/mattermost
. Also, you must run the commands as the user mattermost and specify the location of the configuration file. The executable is /opt/gitlab/embedded/bin/mattermost
.
For example, to get the Mattermost version on GitLab Omnibus:
cd /opt/gitlab/embedded/service/mattermost sudo -u mattermost /opt/gitlab/embedded/bin/mattermost --config=/var/opt/gitlab/mattermost/config.json version
Note
The example commands in the documentation are for a default installation of Mattermost. You must modify the commands so that they work on GitLab Omnibus.
Mattermost 3.6 and later¶
The new CLI tool is supported in Mattermost 3.6 and later. To see available commands in the old CLI tool, see Mattermost 3.5 and earlier.
Notes:
- Parameters in CLI commands are order-specific.
- If special characters (
!
,|
,(
,)
,\
,'
, and"
) are used, the entire argument needs to be surrounded by single quotes (e.g.-password 'mypassword!'
, or the individual characters need to be escaped out (e.g.-password mypassword\!
). - Team name and channel name refer to the handles, not the display names. So in the url
https://pre-release.mattermost.com/core/channels/town-square
team name would becore
and channel name would betown-square
Tip
If you automate user creation through the CLI tool with SMTP enabled, emails will be sent to all new users created. If you run such a load script, it is best to disable SMTP or to use test accounts so that new account creation emails aren’t unintentionally sent to people at your organization who aren’t expecting them.
platform¶
- Description
- Commands for configuring and managing your Mattermost instance and users.
- Options
-c, --config {string} Configuration file to use. (default "config.json")- Child Commands
- platform channel - Management of channels
- platform help - Generate full documentation for the CLI
- platform import - Import data
- platform ldap - LDAP related utilities
- platform license - Licensing commands
- platform reset - Reset the database to initial state
- platform roles - Management of user roles
- platform server - Run the Mattermost server
- platform team - Management of teams
- platform user - Management of users
- platform version - Display version information
- platform config - Work with the configuration file
platform channel¶
- Description
- Commands for channel management.
- Child Commands
- platform channel add - Add users to a channel
- platform channel archive - Archive a channel
- platform channel create - Create a channel
- platform channel delete - Delete a channel
- platform channel list - List all channels on specified teams
- platform channel remove - Remove users from a channel
- platform channel restore - Restore a channel from the archive
platform channel add¶
- Description
- Add users to a channel. If adding multiple users, use a space-separated list.
- Format
platform channel add {channel} {users}- Examples
sudo ./platform channel add 8soyabwthjnf9qibfztje5a36h user@example.com username sudo ./platform channel add myteam:mychannel user@example.com username
platform channel archive¶
- Description
- Archive a channel. Archived channels are not accessible to users, but remain in the database. To restore a channel from the archive, see platform channel restore. Channels can be specified by {team}:{channel} using the team and channel names, or by using channel IDs.
- Format
platform channel archive {channels}- Examples
sudo ./platform channel archive 8soyabwthjnf9qibfztje5a36h sudo ./platform channel archive myteam:mychannel
platform channel create¶
- Description
- Create a channel.
- Format
platform channel create- Examples
sudo ./platform channel create --team myteam --name mynewchannel --display_name "My New Channel" sudo ./platform channel create --team myteam --name mynewprivatechannel --display_name "My New Private Channel" --private- Options
--display_name string Channel Display Name --header string Channel header --name string Channel Name --private Create a private channel. --purpose string Channel purpose --team string Team name or ID
platform channel delete¶
- Description
- Permanently delete a channel along with all related information, including posts from the database. Channels can be specified by {team}:{channel} using the team and channel names, or by using channel IDs.
- Format
platform channel delete {channels}- Examples
sudo ./platform channel delete 8soyabwthjnf9qibfztje5a36h sudo ./platform channel delete myteam:mychannel
platform channel list¶
- Description
- List all channels on a specified team. Archived channels are appended with
(archived)
.- Format
platform channel list {teams}- Example
sudo ./platform channel list myteam
platform channel remove¶
- Description
- Remove users from a channel.
- Format
platform channel remove {channel} {users}- Examples
sudo ./platform channel remove 8soyabwthjnf9qibfztje5a36h user@example.com username sudo ./platform channel remove myteam:mychannel user@example.com username
platform channel restore¶
- Description
- Restore a channel from the archive. Channels can be specified by {team}:{channel} using the team and channel names, or by using channel IDs.
- Format
platform channel restore {channels}- Examples
sudo ./platform channel restore 8soyabwthjnf9qibfztje5a36h sudo ./platform channel restore myteam:mychannel
platform help¶
- Description
- Generate full documentation in Markdown format for the Mattermost command line tools.
- Format
platform help {outputdir}
platform import¶
- Description
- Import data into Mattermost.
- Child Command
- platform import slack - Import a team from Slack.
platform import slack¶
- Description
- Import a team from a Slack export zip file.
- Format
platform import slack {team} {file}- Example
sudo ./platform import slack myteam slack_export.zip
platform ldap¶
- Description
- Commands to configure and synchronize LDAP.
- Child Command
- platform ldap sync - Synchronize now
platform ldap sync¶
- Description
- Synchronize all LDAP users now.
- Format
platform ldap sync- Example
sudo ./platform ldap sync
platform license¶
- Description
- Commands to manage licensing.
- Child Command
- platform license upload - Upload a license.
platform license upload¶
- Description
- Upload a license. This command replaces the current license if one is already uploaded.
- Format
platform license upload {license}- Example
sudo ./platform license upload /path/to/license/mylicensefile.mattermost-license
platform reset¶
- Description
- Completely erase the database causing the loss of all data. This resets Mattermost to its initial state.
- Format
platform reset- Options
--confirm Confirm you really want to delete everything and a DB backup has been performed.
platform roles¶
- Description
- Commands to manage user roles.
- Child Commands
- platform roles member - Remove System Admin privileges from a user
- platform roles system_admin - Make a user into a System Admin
platform roles member¶
- Description
- Remove system admin privileges from a user.
- Format
platform roles member {users}- Example
sudo ./platform roles member user1
platform roles system_admin¶
- Description
- Promote a user to a System Admin.
- Format
platform roles system_admin {users}- Example
sudo ./platform roles system_admin user1
platform server¶
- Description
- Runs the Mattermost server.
- Format
platform server
platform team¶
- Description
- Commands to manage teams.
- Child Commands
- platform team add - Add users to a team
- platform team create - Create a team
- platform team delete - Delete a team
- platform team remove - Remove users from a team
Note
{team-name} value
For the add, delete, and remove commands, you can determine the {team-name} value from the URLs that you use to access your instance of Mattermost. For example, in the following URL the {team-name} value is myteam:
https://example.com/myteam/channels/mychannel
platform team add¶
- Description
- Add users to a team. Before running this command, see the note about {team-name}.
- Format
platform team add {team-name} {users}- Example
sudo ./platform team add myteam user@example.com username
platform team create¶
- Description
- Create a team.
- Format
platform team create- Examples
sudo ./platform team create --name mynewteam --display_name "My New Team" sudo ./platform teams create --name private --display_name "My New Private Team" --private- Options
--display_name string Team Display Name --email string Administrator Email (anyone with this email is automatically a team admin) --name string Team Name --private Create a private team.
platform team delete¶
- Description
- Permanently delete a team along with all related information, including posts from the database. Before running this command, see the note about {team-name}.
- Format
platform team delete {team-name}- Example
sudo ./platform team delete myteam- Options
--confirm Confirm you really want to delete the team and a DB backup has been performed.
platform team remove¶
- Description
- Remove users from a team. Before running this command, see the note about {team-name}.
- Format
platform team remove {team-name} {users}- Example
sudo ./platform team remove myteam user@example.com username
platform user¶
- Description
- Commands to manage users.
- Child Commands
- platform user activate - Activate a user
- platform user create - Create a user
- platform user deactivate - Deactivate a user
- platform user delete - Delete a user and all posts
- platform user deleteall - Delete all users and all posts
- platform user invite - Send a user an email invitation to a team
- platform user migrate_auth - Mass migrate all user accounts to a new authentication type
- platform user password - Set a user’s password
- platform user resetmfa - Turn off MFA for a user
- platform user search - Search for users based on username, email, or user ID
- platform user verify - Verify email address of a new user
platform user activate¶
- Description
- Activate users that have been deactivated. If activating multiple users, use a space-separated list.
- Format
platform user activate {emails, usernames, userIds}- Examples
sudo ./platform user activate user@example.com sudo ./platform user activate username1 username2
platform user create¶
- Description
- Create a user.
- Format
platform user create- Examples
sudo ./platform user create --email user@example.com --username userexample --password Password1 sudo ./platform user create --firstname Joe --system_admin --email joe@example.com --username joe --password Password1- Options
--email string Email --firstname string First Name --lastname string Last Name --locale string Locale (ex: en, fr) --nickname string Nickname --password string Password --system_admin Make the user a system administrator --username string Username
platform user deactivate¶
- Description
- Deactivate a user. Deactivated users are immediately logged out of all sessions and are unable to log back in.
- Format
platform user deactivate {emails, usernames, userIds}- Examples
sudo ./platform user deactivate user@example.com sudo ./platform user deactivate username
platform user delete¶
- Description
- Permanently delete a user and all related information, including posts.
- Format
platform user delete {users}- Example
sudo ./platform user delete user@example.com- Options
--confirm Confirm you really want to delete the user and a DB backup has been performed.
platform user deleteall¶
- Description
- Permanently delete all users and all related information, including posts.
- Format
platform user deleteall- Example
sudo ./platform user deleteall- Options
--confirm Confirm you really want to delete the user and a DB backup has been performed.
platform user invite¶
- Description
- Send a user an email invite to a team. You can invite a user to multiple teams by listing the team names or team IDs.
- Format
platform user invite {email} {teams}- Examples
sudo ./platform user invite user@example.com myteam sudo ./platform user invite user@example.com myteam1 myteam2
platform user migrate_auth¶
- Description
Migrates all user accounts from one authentication provider to another. For example, you can upgrade your authentication provider from email to LDAP. Output will display any accounts that are not migrated successfully.
from_auth
: The authentication service from which to migrate user accounts. Supported options:gitlab
,saml
.to_auth
: The authentication service to which to migrate user accounts. Supported options:ldap
.match_field
: The field that is guaranteed to be the same in both authentication services. For example, if the user emails are consistent set to email. Supported options:username
.- Format
platform user migrate_auth {from_auth} {to_auth} {match_field}- Example
sudo ./platform user migrate_auth email ladp email- Options
--force Ignore duplicate entries on the LDAP server.
platform user password¶
- Description
- Set a user’s password.
- Format
platform user password {user} {password}- Example
sudo ./platform user password user@example.com Password1
platform user resetmfa¶
- Description
- Turns off multi-factor authentication for a user. If MFA enforcement is enabled, the user will be forced to re-enable MFA with a new device as soon as they log in.
- Format
platform user resetmfa {users}- Example
sudo ./platform user resetmfa user@example.com
platform user search¶
- Description
- Search for users based on username, email, or user ID.
- Format
platform user search {users}- Example
sudo ./platform user search user1@example.com user2@example.com
platform user verify¶
- Description
- Verify the email address of a new user.
- Format
platform user verify {users}- Example
sudo ./platform user verify user1
platform version¶
- Description
- Displays Mattermost version information.
- Format
platform version
platform config¶
- Description
- Commands for managing the configuration file.
- Child Command
- platform config validate - Validate the configuration file.
platform config validate¶
- Description
Makes sure the configuration file has the following properties:
- Is valid JSON.
- Has attributes of the correct type, such as bool, int, and str.
- All entries are valid. For example, checks that entries are below the maximum length.
- Format
platform config validate- Example
sudo ./platform config validate
Mattermost 3.5 and earlier¶
Typing sudo ./platform -help
brings up documentation for the CLI tool. To return the help documentation in GitLab omnibus, type
sudo -u mattermost /opt/gitlab/embedded/bin/mattermost --config=/var/opt/gitlab/mattermost/config.json -help
Notes:
- Parameters in CLI commands are order-specific.
- If special characters (
!
,|
,(
,)
,\
,`
, and"
) are used, the entire argument needs to be surrounded by single quotes (e.g.-password 'mypassword!'
, or the individual characters need to be escaped out (e.g.-password mypassword\!
). - Team name and channel name refer to the handles, not the display names. So in the url
https://pre-release.mattermost.com/core/channels/town-square
team name would becore
and channel name would betown-square
Tip
If you automate user creation through the CLI tool with SMTP enabled emails will be sent to all new users created. If you run such a load script, it is best to disable SMTP or to use test accounts so that new account creation emails aren’t unintentionally set to people at your organization who aren’t expecting them.
CLI Documentation:
Mattermost commands to help configure the system
NAME:
platform -- platform configuration tool
USAGE:
platform [options]
FLAGS:
-config="config.json" Path to the config file
-username="someuser" Username used in other commands
-license="ex.mattermost-license" Path to your license file
-email="user@example.com" Email address used in other commands
-password="mypassword" Password used in other commands
-team_name="name" The team name used in other commands
-channel_name="name" The channel name used in other commands
-channel_header="string" The channel header used in other commands
-channel_purpose="string" The channel purpose used in other commands
-channel_type="type" The channel type used in other commands
valid values are
"O" - public channel
"P" - private channel
-role="system_admin" The role used in other commands
valid values are
"" - The empty role is basic user
permissions
"system_admin" - Represents a system
admin who has access to all teams
and configuration settings.
COMMANDS:
-create_team Creates a team. It requires the -team_name
and -email flag to create a team.
Example:
platform -create_team -team_name="name" -email="user@example.com"
-create_user Creates a user. It requires the -email and -password flag,
and -team_name and -username are optional to create a user.
Example:
platform -create_user -team_name="name" -email="user@example.com" -password="mypassword" -username="user"
-invite_user Invites a user to a team by email. It requires the -team_name
and -email flags.
Example:
platform -invite_user -team_name="name" -email="user@example.com"
-join_team Joins a user to the team. It requires the -email and
-team_name flags. You may need to logout of your current session
for the new team to be applied.
Example:
platform -join_team -email="user@example.com" -team_name="name"
-assign_role Assigns role to a user. It requires the -role and
-email flag. You may need to log out
of your current sessions for the new role to be
applied.
Example:
platform -assign_role -email="user@example.com" -role="system_admin"
-create_channel Create a new channel in the specified team. It requires the -email,
-team_name, -channel_name, -channel_type flags. Optional you can set
the -channel_header and -channel_purpose.
Example:
platform -create_channel -email="user@example.com" -team_name="name" -channel_name="channel_name" -channel_type="O"
-join_channel Joins a user to the channel. It requires the -email, -channel_name and
-team_name flags. You may need to logout of your current session
for the new channel to be applied. Requires an enterprise license.
Example:
platform -join_channel -email="user@example.com" -team_name="name" -channel_name="channel_name"
-leave_channel Removes a user from the channel. It requires the -email, -channel_name and
-team_name flags. You may need to logout of your current session
for the channel to be removed. Requires an enterprise license.
Example:
platform -leave_channel -email="user@example.com" -team_name="name" -channel_name="channel_name"
-list_channels Lists all channels for a given team.
It will append ' (archived)' to the channel name if archived. It requires the
-team_name flag. Requires an enterprise license.
Example:
platform -list_channels -team_name="name"
-restore_channel Restores a previously deleted channel.
It requires the -channel_name flag and
-team_name flag. Requires an enterprise license.
Example:
platform -restore_channel -team_name="name" -channel_name="channel_name"
-reset_password Resets the password for a user. It requires the
-email and -password flag.
Example:
platform -reset_password -email="user@example.com" -password="newpassword"
-reset_mfa Turns off multi-factor authentication for a user. It requires the
-email or -username flag.
Example:
platform -reset_mfa -username="someuser"
-reset_database Completely erases the database causing the loss of all data. This
will reset Mattermost to it's initial state. (note this will not
erase your configuration.)
Example:
platform -reset_database
-permanent_delete_user Permanently deletes a user and all related information
including posts from the database. It requires the
-email flag. You may need to restart the
server to invalidate the cache
Example:
platform -permanent_delete_user -email="user@example.com"
-permanent_delete_all_users Permanently deletes all users and all related information
including posts from the database. It requires the
-team_name, and -email flag. You may need to restart the
server to invalidate the cache
Example:
platform -permanent_delete_all_users -team_name="name" -email="user@example.com"
-permanent_delete_team Permanently deletes a team along with
all related information including posts from the database.
It requires the -team_name flag. You may need to restart
the server to invalidate the cache.
Example:
platform -permanent_delete_team -team_name="name"
-upload_license Uploads a license to the server. Requires the -license flag.
Example:
platform -upload_license -license="/path/to/license/example.mattermost-license"
-migrate_accounts Migrates accounts from one authentication provider to another.
Requires -from_auth -to_auth and -match_field flags. Supported
options for -from_auth: email, gitlab, saml. Supported options
for -to_auth: ldap. Supported options for -match_field: email,
username. Output will display any accounts that are not migrated
successfully.
Example:
platform -migrate_accounts -from_auth email -to_auth ldap -match_field username
-upgrade_db_30 Upgrades the database from a version 2.x schema to version 3 see
http://www.mattermost.org/upgrading-to-mattermost-3-0/
Example:
platform -upgrade_db_30
-version Display the current of the Mattermost platform
-help Displays this help page